package com.yn.xgame.game;

import com.google.common.collect.ImmutableList;
import com.yn.xgame.CommonConfig;
import com.yn.xgame.util.Utils;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

/**
 * Game
 * Created by wangboo on 17/7/18.
 */
public class GameConfig extends CommonConfig {

    private ImmutableList<String> gameTopicList;
    private ImmutableList<String> gameNameList;

    public GameConfig(String file) throws IOException {
        super("", file);
        String topics = prop.getProperty("game.topics");
        if (topics == null) throw new RuntimeException("gameTopic is null!!");
        gameTopicList = ImmutableList.copyOf(topics.split(","));
        Set<String> gameSet = new HashSet<>();
        gameTopicList.forEach(t -> gameSet.add(Utils.getPrefixWord(t)));
        gameNameList = ImmutableList.copyOf(gameSet);
    }
    // 废弃 @use getTopicList
    @Deprecated
    public String getTopic() {
        return super.getTopic();
    }

    /**
     * 获取游戏订阅的子游戏列表
     */
    public ImmutableList<String> getTopicList() {
        return gameTopicList;
    }

    public ImmutableList<String> getGameNameList() {
        return gameNameList;
    }
}
